package com.java.androidmarket.exception;

import lombok.Getter;
import lombok.Setter;

/**
 * description:
 * author:张腾
 * date:2021-05-21
 */

public class ApiException extends RuntimeException{

    private static final long serialVersionUID = 1L;

    /** 错误码 */
    @Getter
    @Setter
    protected String errorCode;

    /** 错误信息 */
    @Getter
    @Setter
    protected String errorMsg;

    public ApiException(){
        super();
    }

    public ApiException(BaseErrorInfo baseErrorInfo){
        super(baseErrorInfo.getResultCode());
        this.errorCode = baseErrorInfo.getResultCode();
        this.errorMsg = baseErrorInfo.getResultMsg();
    }

    public ApiException(BaseErrorInfo baseErrorInfo, Throwable cause){
        super(baseErrorInfo.getResultCode(), cause);
        this.errorCode = baseErrorInfo.getResultCode();
        this.errorMsg = baseErrorInfo.getResultMsg();
    }

    public ApiException(String errorMsg) {
        super(errorMsg);
        this.errorMsg = errorMsg;
    }

    public ApiException(String errorCode, String errorMsg) {
        super(errorCode);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public ApiException(String errorCode, String errorMsg, Throwable cause) {
        super(errorCode, cause);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }


    public String getMessage() {
        return errorMsg;
    }

    @Override
    public Throwable fillInStackTrace() {
        return this;
    }

}
